//
//  LRBaseVC.m
//  LrjhIOS
//
//  Created by jun on 2020/10/29.
//  Copyright © 2020 AXE. All rights reserved.
//

#import "LRBaseVC.h"
#import "LRDialog.h"

@interface LRBaseVC ()


@end

@implementation LRBaseVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)showAlertInfo:(NSString*)message okClick:(OkBolck)okClick{
    LRDialog *dialog = [LRDialog dialog:@"Warm Tip!" message:message btnTitle:@"Ok" btnCancelTitle:@"Cancel"];
    dialog.block = ^{
        if(okClick){
            okClick();
        }
    };
    [dialog show];
}

-(void)showTipInfo:(NSString*)message okClick:(OkBolck)okClick{
    LRDialog *dialog = [LRDialog dialog:@"Warm Tip!" message:message btnTitle:@"Ok" btnCancelTitle:@""];
       dialog.block = ^{
           if(okClick){
               okClick();
           }
       };
 
    [dialog show];
}




-(void)toRootViewController{
    
    NSArray *viewControlles = self.navigationController.viewControllers;
    UIViewController *viewController = nil;
    
    if ([viewControlles count] > 0) {
        viewController = viewControlles[0];
    }
    if(viewController){
        [self.navigationController popToViewController:viewController animated:NO];
    }
}

-(void)jumpViewControllerAndCloseSelf:(UIViewController *)vc{
    NSArray *viewControlles = self.navigationController.viewControllers;
    NSMutableArray *newviewControlles = [NSMutableArray array];
    if ([viewControlles count] > 0) {
        for (int i=0; i < [viewControlles count]-1; i++) {
            [newviewControlles addObject:[viewControlles objectAtIndex:i]];
        }
    }
    vc.hidesBottomBarWhenPushed = YES;
    [newviewControlles addObject:vc];
    self.navigationController.viewControllers = [newviewControlles copy];
}

-(void)go2VC:(UIViewController *)vc{
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}


-(void)toast:(NSString*)text{
    [self.view makeToast:text duration:2 position:CSToastPositionCenter];
}

-(void)makeProgress:(NSString*)text{
    [self.view makeToastActivity:CSToastPositionCenter];
}

@end
